

  load "m7_logtail.ncl" 

   fna = "sgp_wrf.nc" 

   fla = addfile(fna,"w")

   duac = fla->duac 
   duco = fla->duco 
   dgac = fla->dgac 
   dgco = fla->dgco

   nac = duac
   nco = duco
   nac@units = "#/L"
   nco@units = "#/L"

   pi=3.1415926d0 
   sgai=1.7d0 
   sgac=2.2d0 
   sgco=1.75d0 

   f1=pi*(dgac^3)/6.0d0
   f2=exp(4.5d0*(log(sgac))^2)
   f3=duac*1.d-9/(2.6d3)  ;;ug/m3 to kg/m3, g/cc to kg/m3, final m3/m3 vac
   nac = doubletofloat(f3/(f1*f2)) 

   f1=pi*(dgco^3)/6.0d0
   f2=exp(4.5d0*(log(sgco))^2)
   f3=duco*1.d-9/(2.6d3)  ;;ug/m3 to kg/m3, g/cc to kg/m3, final m3/m3
   nco = doubletofloat(f3/(f1*f2)) ;; #/m3 

   nac = nac / 1.e3 
   nco = nco / 1.e3 


   ;;nac = nac * 0.1 

   ;; get > 100nm fraction 

   dct = 2.d-7 ;; 100nm radius 

   ;; transform number distribution to error function:

   ztn = (log(dct) - log(dgac)) / sgac

   ratio = nac * 0.d0

   nt = dimsizes(nac(:,0)) 
   nk = dimsizes(nac(0,:)) 

   do it = 0, nt-1 
   do ik = 0, nk-1 
;;      print("dgac(it,ik) : "+dgac(it,ik)) 
;;      print("ztn(it,ik) : "+ztn(it,ik)) 
      ratio(it,ik) = m7_cumnor(ztn(it,ik)) 
   end do 
   end do 

   print("ratio : "+ratio) 

   ;; calculate the cumulative of the log-normal number distribution:

   ;;CALL m7_cumnor(ztn,zdummy,pfracn(jl,jk,jmod))

   nac = nac * doubletofloat(ratio)

   fla->num_dust=nac
   fla->num_dust_cs=nco



